# import smtplib
# from email.mime.text import MIMEText
# from email.mime.multipart import MIMEMultipart
# from email.mime.image import MIMEImage
from config import *
#
# mail_host = 'smtp.163.com'
# mail_user = 'hzn9804@163.com'
# mail_pass = 'QGPLAMNBDQHKFOHE'
# sender = 'hzn9804@163.com'
# receivers = ['344242221@qq.com']
#
# message = MIMEMultipart()
# message['Subject'] = '{}涨粉趋势'.format(day)
# message['from'] = sender
# message['To'] = receivers[0]
#
# content = MIMEText('{}涨粉趋势'.format(day), 'plain', 'utf-8')
#
# with open('img/img-{}.png'.format(day), 'rb') as fp:
#     picture = MIMEImage(fp.read())
#     picture['Content-Type'] = 'application/octet-stream'
#     picture['Content-Disposition'] = 'attachment;filename="img-{}.png"'.format(day)
#
# message.attach(content)
# message.attach(picture)
#
# try:
#     smtpObj = smtplib.SMTP()
#     smtpObj.connect(mail_host, 25)
#     smtpObj.login(mail_user, mail_pass)
#     smtpObj.sendmail(
#         sender, receivers, message.as_string()
#     )
#     smtpObj.quit()
# except smtplib.SMTPException as e:
#     print('error', e)

import yagmail

yag = yagmail.SMTP(
    user='hzn9804@163.com',
    password='QGPLAMNBDQHKFOHE',
    host='smtp.163.com',
    port='465'
)
body = '{}涨粉趋势'.format(day)
img = 'img/img-{}.png'.format(day)

yag.send(to='344242221@qq.com', subject='{}涨粉趋势'.format(day), contents=[body, img])